/*
   Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
   Original sources are available at www.latestbit.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

#ifndef OSTOOLS_HPP
#define OSTOOLS_HPP

#include "cpputils/CppUtils.hpp"

namespace cpputils {
	namespace utils {

		/**
		 * Auxiliary static functions for management processes which hides hides OS specific implementation
		 */
		class OSTools {
		public:
			/**
			 * Run process in async manner (with command line arguments)
			 * @param sProcessPath Path to executable process
			 */
			CPPU_DLLPRFX static spawn_pid_t runAsyncProcess(const char* sProcessPath, ...);

			/**
			 * Waiting to finish process
			 * @param nProcessId PID which is received from runAsyncProcess
			 * @sa runAsyncProcess
			 */
			CPPU_DLLPRFX static void waitProcess(spawn_pid_t nProcessId);

			/**
			 * Get the current process id
			 */
			CPPU_DLLPRFX static spawn_pid_t getCurrentProcessId();

			/**
			 * Get the current thread id
			 */
			CPPU_DLLPRFX static thread_id_t getCurrentThreadId();

			/**
			 * Equality check for threads id
			 */
			CPPU_DLLPRFX static bool equalThreadId(thread_id_t hOne, thread_id_t hTwo);

			/**
			 * Get the OS/mach specific performance (CPU) frequency of the high-resolution performance counter.
			 * @note The frequency cannot change while the system is running
			 */
			CPPU_DLLPRFX static hrtime_t gethrfreq();

			/**
			 * Get current High-Resolution time.
			 */
			CPPU_DLLPRFX static hrtime_t gethrtime();

			/**
			 * Get current locale (country + language code) as ISO 3166 string
			 */
			CPPU_DLLPRFX static std::string getCurrentLocale();
		};

	}
}

#endif // OSTools_HPP
